// pages/index/landlordDirectRental/landlord/landlord.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    home:[],
    userId:0,
    user:[],
    reportList:[],
    type: 1,
    fangdongId: 1,
    reputationList:[],
    //userId: parseInt(wx.getStorageSync('userInfo').userId, 10), // 转换为整数类型,
  },
  getUserHouse(){
    wx.request({
      url: 'http://localhost:8080/ihome/home/house',
      data:{
        userId:this.data.userId
      },
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token')
      },
      success:(resp=>{
        this.setData({
          home:resp.data.rows
        })
        //  console.log(resp.data.rows)
      })
    })
  },
  getUser(){
    wx.request({
      url: 'http://localhost:8080/system/user/'+this.data.userId,
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token')
      },
      success:(resp=>{
        this.setData({
          user:resp.data.data
        })
        //  console.log(resp.data.data)
      })
    })
  },
  getReport(){
    wx.request({
      url: 'http://localhost:8080/biz/reportrInformation/list',
      data:{
        userId:this.data.userId
      },
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token')
      },
      success:(resp=>{
        this.setData({
          reportList:resp.data.rows
        })
        // console.log(this.data.userId)
        //  console.log(resp.data)
      })
    })
  },
  //信誉
  getReputation(){
    wx.request({
      url: 'http://localhost:8080/ihome/integral/list',
      data:{
        userId:this.data.userId
      },
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token')
      },
      success:(resp=>{
        this.setData({
          reputationList:resp.data.rows
        })
        // console.log(this.data.userId)
        // console.log(resp.data.rows)
      })
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      userId:options.id
    })
    // console.log(options)
    this.getUserHouse();
    this.getUser();
    this.getReport();
    this.getReputation();
  },
  navigateToReport1() {
    // console.log(1515)
    // 存储数据到本地缓存
    wx.setStorageSync('houseId', this.data.fangdongId);
    wx.setStorageSync('userId', this.data.userId);
    // 导航到目标页面
    wx.navigateTo({
      url: '/pages/index/home/report/report?type=' + this.data.type
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})